<template>
  <div>
    <h1>首页</h1>
    <p v-if="username">{{ username }}</p>
    <p v-else><router-link to="/login">登录</router-link></p>
    <table border="1px" align="center">
      <tr>
        <td><font color="red">年级</font></td>
        <td colspan="3"><font color="red">课程</font></td>
      </tr>
      <tr v-for="i in data_list" :key="i.id">
        <td>{{ i.grade.name }}</td>
        <td>{{ i.classes_list[0].name }}</td>
        <td>{{ i.classes_list[1].name }}</td>
        <td>{{ i.classes_list[2].name }}</td>
      </tr>
    </table>
    <p v-show="username">
      <button><font style="color: #1e90ff">点击提升班级</font></button>
    </p>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      data_list: [],
      base_url: "http://127.0.0.1:8000",
      uid: sessionStorage.getItem("uid"),
      username: sessionStorage.getItem("username"),
    };
  },
  created() {
    axios({
      url: this.base_url + "/app1/classes/" ,
    }).then((resp) => {
      console.log(resp.data);
      this.data_list = resp.data;
    });
  },
};
</script>

<style>
</style>